const express=require('express');
const static=require('express-static');
const mysql=require('mysql');

let server=express();

    server.listen(100);

let db=mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'',
    database:'test',
    useConnectionPooling:true
})
server.get('/getsudydata',(request,response)=>{
    let dataStr=`select * from study`;
    db.query(dataStr,(err,data)=>{
        console.log(data)
          if(err){
              response.send({
                  error:1,
                  desc:'数据库出错'
              });
              response.end();
          }else {
              response.send({
                   error:0,
                   data
              })
              response.end()
          }
    })
})

server.use(static('www'));